package net.huashitong.scheduling.web;

import java.util.ArrayList;
import java.util.List;

import net.huashitong.Indicators.databean.CompletionClassificationDatabean;
import net.huashitong.Indicators.entity.CompletionClassification;
import net.huashitong.Indicators.filter.CompletionClassificationFilter;
import net.huashitong.scheduling.entity.Gdp;
import net.huashitong.scheduling.service.GdpService;
import net.huashitong.scheduling.service.PreemptiveService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.Message;
/**
 * 争先进位
 * @author lzr
 *
 */
@Controller
@RequestMapping("/app/preemptive")
public class PreemptiveController extends JsonBaseController {

	@Autowired
	private PreemptiveService preemptiveService;
	@Autowired
	private GdpService gdpService;
	@Override
	protected String getView(String arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	 * 查找扶贫县数据
	 */
	@ResponseBody
	@RequestMapping("/queryCountyPreemptive")
	public Message queryCountyPreemptive(@RequestBody CompletionClassificationFilter filter){
		List<CompletionClassification> classifications = preemptiveService.queryCountyPreemptive(filter);
		List<CompletionClassificationDatabean> classificationDatabeans = new ArrayList<CompletionClassificationDatabean>();
		for (CompletionClassification completionClassification : classifications) {
			CompletionClassificationDatabean classificationDatabean = new CompletionClassificationDatabean();
			classificationDatabean.setActualCompletionValue(completionClassification.getActualCompletionValue());
			classificationDatabean.setUnit("亿元");
			classificationDatabean.setArea(completionClassification.getArea());
			classificationDatabeans.add(classificationDatabean);
		}
 		return coverMessage("200", "数据获取成功", classificationDatabeans);
	}
	/**
	 * 前六末六数据
	 */
	@ResponseBody
	@RequestMapping("/queryPreemptive")
	public Message queryPreemptive(@RequestBody CompletionClassificationFilter filter){
		filter.setCategory("争先进位");
		filter.setIndustryId("A01");
		filter.setCompletionPeriod("201701-10");
		List<CompletionClassificationDatabean> classificationDatabeans = preemptiveService.queryPreemptive(filter);
 		return coverMessage("200", "数据获取成功", classificationDatabeans);
	}
	
	public Message queryGdpList(@RequestBody CompletionClassificationFilter filter){
		List<Gdp> GdpList=gdpService.queryByDate("");
		return coverMessage("200", "数据获取成功", "");
	}
}
